package com.wangp.spider.main;

import java.io.IOException;
import java.util.List;

import org.apache.http.ParseException;
import org.apache.http.client.HttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.wangp.spider.entity.JDModel;
import com.wangp.spider.util.URLFecter;

public class MainApplication {
	
	private static Logger logger = LoggerFactory.getLogger(MainApplication.class);
	
	public static void main(String[] args) throws ParseException, IOException {
		
		HttpClient client = HttpClientBuilder.create().build();
		
		String url = "https://search.jd.com/Search?keyword=%E6%98%8E%E6%9C%9D%E9%82%A3%E4%BA%9B%E4%BA%8B&enc=utf-8&suggest=1.def.0.V15&wq=mingchao&pvid=38816f8a552b4f139da88fc3cad69fbf";
		
		List<JDModel> bookdatas = URLFecter.URLParse(client,url);
		int i = 1 ;
		for(JDModel jd : bookdatas){
			
			System.out.println("No:" + i++ + "\t"+""+"bookId:" + jd.getBookId() + "\t" + "bookName:" + jd.getBookName() + "\t" + "bookPrice:" + jd.getBookPrice());
			logger.info("bookId:" + jd.getBookId() + "\t" + "bookName:" + jd.getBookName() + "\t" + "bookPrice:" + jd.getBookPrice());
		}
		
		
		
	}

}
